﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Hosting;

namespace Winsmarts.WCFSupport
{
    public class WCFVPPRegModule : IHttpModule
    {
        static bool wcfProviderInitialized = false;
        static object locker = new object();

        public void Init(HttpApplication context)
        {
            if (!wcfProviderInitialized)
            {
                lock (locker)
                {
                    if (!wcfProviderInitialized)
                    {
                        WCFVirtualPathProvider wcfVPP = new WCFVirtualPathProvider();
                        HostingEnvironment.RegisterVirtualPathProvider(wcfVPP);
                        wcfProviderInitialized = true;
                    }
                }
            }
        }

        public void Dispose()
        {
            // Nothing required.
        }
    }
}
